<?php
include "includes/ui.php";
$approve=0;
if (isset($_GET['t'])){
	if ($_GET['t']=='ap'){
		$approve=1;
		$name="อนุมัติสั่งซื้อพัสดุ /พัสดุ";
		if ($_SESSION['permission'][$page]['ap']!="1") {
			echo "<meta http-equiv = refresh ; content = '0 ; url = purchase.php'>";
			exit();
		}
	}
}else {
	$name = "สั่งซื้อสินค้า/พัสดุ";
	$approve=0;
}

echo headerHTML("stock", $name);
?> 
 
 
<input type="hidden" id="approve" value="<?php echo $approve; ?>" />
<div id="popup" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style='margin-left:-390px;width:860px;'>

    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
        <h3 id="myModalLabel"><i class="icon-cog"></i> รายการสั่งซื้อพัสดุ </h3>
    </div>

    <form class="form-horizontal" id="frmPurchase" style="margin-bottom: 0px!important;" method="POST">
		<input type='hidden' name='pid' id='pid' value=''/>
		<input type='hidden' name='mode' id='mode' value='po'/>
        <div class="modal-body" style="overflow-y:auto;min-height:400px;">
            <div class="control-group">
                <label class="control-label" for="inputName"  style='width:120px !important;font-weight:bold;'><i class="icon-double-angle-right"></i> เลขที่ใบสั่งซื้อ</label>
                <div class="controls" style='margin-left:120px !important;'>
                    <input type="text" id="txtPONo_" class="span1" readonly style="width:120px;color:blue;" required maxlength="15">

                    <span class="help-inline" style="font-weight:bold;margin-left:30px;">วันที่สั่งซื้อ&nbsp;</span>

                    <input class="span1" style="width:100px !important;" data-date-format="dd/mm/yyyy" id='txtPurchaseDate' required size="16" type="text"  readonly="">
                
					<span class="help-inline" style="font-weight:bold;margin-left:30px;"> ผู้สั่งซื้อ&nbsp;</span><span class="help-inline" style="font-weight:normal;"><?php echo $_SESSION['login_name'];?></span>
					
					<!---select id='cboEmployee' class='select_emp' data-live-search="true" style='width:200px;'>
                    </select-->
					
				</div>
            </div>
			<div class="control-group">
				<label class="control-label" for="inputName"  style='width:120px !important;font-weight:bold;'><i class="icon-double-angle-right"></i> ผู้ขาย </label>
                <div class="controls" style='margin-left:120px !important;'>
                    <select id='cbosupplier'  style='width:350px;'>
                    </select>
				</div>
			</div>
            <div class="control-group">
                <label class="control-label" for="inputName"  style='width:120px !important;font-weight:bold;'><i class="icon-double-angle-right"></i> หมายเหตุ</label>
                <div class="controls" style='margin-left:120px !important;'>
                    <input type="text" id="txtRemark" class='span6' maxlength="300">

                </div>
            </div>
            <div class="well no-padding">
                <label class="control-label hidden_control" for="inputName"  style='width:120px !important;font-weight:bold;'><i class="icon-double-angle-right"></i> เลือกรายการ</label>
                <div style="padding:5px;background-color:#ffffff;" class='hidden_control'>
                    <select id='cboType' style='width:130px;'>
                    </select>
					<select id='cboProduct' class='select_product' data-live-search="true" style='width:200px;'>
                    </select>
                    <!--input type="text" id="txtProduct"    data-provide="typeahead"  data-items="5" data-source="" class='span3' placeholder="...." /-->
                    <input type="text" id="txtAmount"  rel="tooltip" title=""   data-original-title="จำนวนรายการ" class='span1 text-right' value="1" maxlength="4" />
					 <input type="text" id="txtPrice"  placeholder="ราคา" rel="tooltip" title=""   data-original-title="ราคา"  class='span1 text-right' style='width:100px;' maxlength="6" />
                    <input type="text" id="txtDiscount"  placeholder="ส่วนลด" rel="tooltip" title=""   data-original-title="ส่วนลด"  style='width:80px;' class='span1 text-right' maxlength="4" />
                    <button class="btn btn-inverse" rel="tooltip" title="" id='btnAddProduct' type='button'   data-original-title="เพิ่มรายการ" >เพิ่ม</button>
                </div>
                <span class="help-inline text-center" id='Error' style="display:none;font-weight:bold;margin: auto;text-align: center;width: 100%;color: red !important;background-color: white;">กรุณาเลือกรายการ&nbsp;</span>
                <!-- Add News: WYSIWYG Edior -->
                <table class="table" id='table_detail' style='width:100% !important;'>
                    <thead>
                        <tr>
                            <th style='color:#333 !important;width:30px;'>#</th>
                            <th style='color:#333 !important;display:none; '>0</th>
							<th style='color:#333 !important;width:70px;' class='text-center'>รหัส</th>
                            <th style='color:#333 !important;width:100px;' class='text-center'>ประเภท</th>
                            <th style='color:#333 !important;' class='text-center'>รายการสินค้า</th>
                            <th style='color:#333 !important;width:80px;' class='text-center'>จำนวน</th>
                            <th style='color:#333 !important;width:100px;' class='text-center'>ราคา/หน่วย</th>
                            <th style='color:#333 !important;width:100px;' class='text-center'>ส่วนลด</th>
                            <th style='color:#333 !important;width:100px;' class='text-center'>รวม</th>
                            <th style='color:#333 !important;width:40px;' class='text-center'>ยกเลิก</th>
                        </tr>
                    </thead>
                    <tbody>

                    </tbody>
                </table>
                <!-- / Add News: WYSIWYG Edior -->

            </div> 
        </div>

        <div class="modal-footer">
			<button type='button' class="btn btn-success approve_control" id="btnApp">อนุมัติ</button>
			<button type='button' class="btn btn-warning approve_control" id="btnNotApp">ไม่อนุมัติ</button>
            <button type='submit' class="btn btn-primary hidden_control" id="btnSave">ส่งรายการ</button>
			<button type='submit' class="btn btn-info approved_control" id="btnPrint">พิมพ์</button>
            <button class="btn" data-dismiss="modal" id='btnCancel' aria-hidden="true">ยกเลิก</button>

        </div>
    </form>

</div> 
<!-- Live Stats -->
<div class="row-fluid">

    <!-- Pie: Box -->
    <div class="span12">

        <!--  : Top Bar -->
        <div class="top-bar">
            <h3><i class="icon-cog"></i>  <?php echo $name;?></h3>
            <?php
            if ($approve != 1) {
                ?>
                <div class='tmp' style='float:right'>
                    <a href="#popup" data-toggle="modal">
                        <button class="btn btn-info"    id='btnAdd' tooltip="Add">สั่งซื้อพัสดุ</button>
                    </a>
                </div>
            <?php }?> 
        </div>
        <!-- /  : Top Bar -->

        <!-- Pie: Content -->
        <div class="well no-padding" >
            <div class="span12">
                <form class="form-horizontal" style='margin-bottom:0px;'>
                    <div class="row-fluid">
                        <div class='span12'>
                            <div class="control-group">
                                <label class="control-label"  for="inputName"><i class="icon-double-angle-right"></i>เลขที่ใบสั่งซื้อ</label>
                                <div class="controls">
                                    &nbsp;&nbsp;&nbsp;<input type="text" id="txtPurchaseNo_S" placeholder="">
                                    <span class="help-inline" style="font-weight:bold;margin-left:70px;">ผู้ขาย&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
                                    <select id='cbosupplier_s' class='select_text' style='width:250px;'>
									</select> 
                                </div>
                            </div>

                            <div class="control-group" >
                                <label class="control-label" ><i class="icon-double-angle-right"></i>สถานะ</label>
                                <div class="controls">

                                    &nbsp;&nbsp;&nbsp;<select class="no-margin span8" id="cboPurchase"  style="width:200px !important;"></select>
                                    <span class="help-inline" style="font-weight:bold;margin-left:70px;">วันที่สั่งซื้อ &nbsp;&nbsp;</span>
                                    
                                    <div class="input-append date btndate1"   data-date="12-02-2012"  data-date-format="dd/mm/yyyy">
                                        <input class="span1" style="width:100px !important;" id='txtDateFrom_s' size="16" type="text"  readonly="">
                                        <span class="add-on"><i class="icon-calendar"></i></span>
                                    </div>

                                    &nbsp;
                                    <div class="input-append date btndate2"   data-date="12-02-2012"  data-date-format="dd/mm/yyyy">
                                        <input class="span1" style="width:100px !important;" id='txtDateTo_s' size="16" type="text"  readonly="">
                                        <span class="add-on"><i class="icon-calendar"></i></span>
                                    </div>
                                    <button class="btn btn-inverse" type='button' id='btnSearch' style='height:30px;margin-left:50px;margin-top:0px;padding-top:0px;' rel="tooltip" title=""   data-original-title="ค้นหาข้อมูล"><i class="icon-search"></i></button> 	
                                </div>

                            </div>

                        </div>

                    </div>
                </form>
            </div>
            <table class="data-table" id='resultData'>
                <thead style='border-top:1px solid #c2c2c2;border-bottom:1px solid #c2c2c2;'> 
                    <tr >
                        <th style='color:#333 !important;width:20px;'>#</th>
                        <th style='color:#333 !important;display:none'>0</th>
                        <th style='color:#333 !important;width:100px !important;' class='center'>วันที่</th>
                        <!--th style='color:#333 !important;width:120px !important;' class='center'>เลขที่ใบขอซื้อ</th-->
                        <th style='color:#333 !important;width:120px !important;' class='center'>เลขที่ใบสั่งซื้อ</th>
						<th style='color:#333 !important;' class='center'>ผู้ขาย</th>
						<th style='color:#333 !important;width:120px !important;' class='center'>ผู้สั่งซื้อ</th>
                        <th style='color:#333 !important;width:80px !important;' class="center">จำนวน</th>
                        <th style='color:#333 !important;width:90px !important;' class="text-center">จำนวนเงิน</th>
                        <th style='color:#333 !important;width:90px !important;' class="text-center">ส่วนลด</th>
                        <th style='color:#333 !important;width:90px !important;' class="text-center">รวมทั้งหมด</th>
                        <th style='color:#333 !important;width:120px;' class="center">สถานะ </th>
                        <th style='color:#333 !important;display:none'>0</th>
                        <th style='color:#333 !important;width:50px !important;' class="center">ดูข้อมูล </th>
                        <th style='color:#333 !important;width:50px !important;' class="center">ยกเลิก </th>
                    </tr>
                </thead>
                <tbody>
                 
                </tbody>

            </table>

        </div>
        <!-- / Pie: Content -->

    </div>
    <!-- / Pie -->

</div>
<!-- / Live Stats -->

<?php
echo footerHTML();
?>

<!-- Javascript======================================= -->
<!-- Placed at the end of the document so the pages load faster -->
<script src='js/jquery.hotkeys.js'></script>
<!--script src='js/fullcalendar.min.js'></script-->
<!--script src="js/jquery-ui-1.10.2.custom.min.js"></script-->
<script src="js/jquery.jqCombo.min.js"></script>
<script src="js/jquery.pajinate.js"></script>
<!--script src="js/jquery.prism.min.js"></script-->
<script src="js/jquery.dataTables.min.js"></script>

<script src="js/jquery.flot.resize.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/bootstrap-wysiwyg.js"></script>
<script src="js/bootstrap-typeahead.js"></script>
<script src="js/jquery.easing.min.js"></script>
<script src="js/jquery.chosen.min.js"></script>
<script src="js/avocado-custom.js"></script>
<script src="js/jqBootstrapValidation.js"></script>
<script src="js/bootstrap-datepicker.js"></script>

<script src="js/bootstrap-select.min.js"></script>
<script src="js/myScript/js_purchase.js"></script>
</html>